package top.rainbowecho.notify.infrastructure.mq.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import top.rainbowecho.common.mq.config.BlogMqRouteEnum;
import top.rainbowecho.common.mq.listener.ListenerConfig;

/**
 * @author rainbow
 * @since 2019/12/13 15:40
 */
@Configuration
public class MailListenerConfig extends ListenerConfig {

    @Bean
    public Queue mailQueue() {
        return new Queue(getRouting(BlogMqRouteEnum.GATEWAY_TO_MAIL));
    }

    @Bean
    public TopicExchange mailExchange() {
        return new TopicExchange(getExchange(BlogMqRouteEnum.GATEWAY_TO_MAIL));
    }

    @Bean
    public Binding mailBinding() {
        return BindingBuilder.bind(mailQueue()).to(mailExchange()).with(getRouting(BlogMqRouteEnum.GATEWAY_TO_MAIL));
    }
}
